Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
Rollup / Babel / CoreJS - "Require is not defined"

I'm trying to use Rollup.js to build some JS to be compatible with IE11. After a very frustrating couple of hours fiddling with various config options, I hit upon the following:

import resolve from "@rollup/plugin-node-resolve"
import { babel } from '@rollup/plugin-babel';

export default {
  input: "app/javascript/application.js",
  output: {
    file: "app/assets/builds/application.js",
    format: "es",
    inlineDynamicImports: true,
    sourcemap: true
  },
  plugins: [
    babel({
      presets: [
        [
          "@babel/preset-env", {
            "useBuiltIns": "usage",
            "debug": true,
            "corejs": "3"
          }
        ]
      ]
    }),
    resolve(),
  ]
}

Looking at the debug entries, it seems that my polyfills are getting added (yay?). However it seems that they're getting added with requires for some reason, as when I try to run the JS in my browser, I get:

Uncaught ReferenceError: require is not defined

The offending lines of code seem to be:

var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');

var redefine$2 = require('../internals/redefine');

var toString$3 = require('../internals/object-to-string'); // `Object.prototype.toString` method
// https://tc39.es/ecma262/#sec-object.prototype.tostring

But I don't understand why this should be, surely if Babel is transpliling code for the browser, then require should be nowhere near my code? Please help, I'm tearing what little hair I have remaining out over this!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda